package com.lzx.iteam.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.lzx.iteam.R;
import com.lzx.iteam.bean.SalaryListBean;
import com.lzx.iteam.util.DateUtil;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * **********************************
 * User: zhangshuai
 * Date: 2017年 01月 18日
 * Time: 下午3:30
 *
 * @QQ : 1234567890
 * **********************************
 */
public class SalaryListAdapter extends BaseAdapter {

    private Context mContext;
    private ArrayList<SalaryListBean> mData;

    public SalaryListAdapter(Context mContext, ArrayList<SalaryListBean> mData) {
        this.mContext = mContext;
        this.mData = mData;
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null){
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.salary_list_item_layout,null);
            holder.name = (TextView) convertView.findViewById(R.id.tv_salary_item_name);
            holder.time = (TextView) convertView.findViewById(R.id.tv_salary_item_time);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        SalaryListBean bean = mData.get(position);
        holder.name.setText(bean.getMonth());
        holder.time.setText(DateUtil.getMDHMTime(Long.parseLong(bean.getCreate_time()) * 1000));
        return convertView;
    }

    class ViewHolder{
        private TextView name;
        private TextView time;

    }
}
